# -*- coding: utf-8 -*-

from sacred import Experiment
from sacred.observers import FileStorageObserver
from Config import config_ingredient
import Estimate_Sources
import os

test_file_list = ['p232_060', #input list of test files to loop over (in this case, from Voice Bank dataset)
'p257_362',
'p257_283',
'p257_180',
'p232_061',
'p232_211',
'p232_183',
'p232_106',
'p232_022',
'p232_278',
'p232_003',
'p257_259',
'p257_402',
'p257_171',
'p232_024',
'p257_385',
'p232_117',
'p257_143',
'p232_119',
'p257_364',
'p232_071',
'p232_037',
'p232_357',
'p257_192',
'p232_170',
'p232_341',
'p232_269',
'p232_179',
'p257_157',
'p257_056',
'p257_049',
'p232_028',
'p232_230',
'p232_263',
'p232_054',
'p257_432',
'p257_182',
'p232_014',
'p257_135',
'p232_178',
'p232_377',
'p232_334',
'p232_249',
'p257_217',
'p257_012',
'p232_237',
'p257_398',
'p257_284',
'p232_248',
'p232_226',
'p232_091',
'p232_321',
'p257_093',
'p232_344',
'p232_259',
'p257_133',
'p257_271',
'p257_330',
'p257_264',
'p232_033',
'p257_191',
'p257_418',
'p257_260',
'p257_234',
'p257_208',
'p232_313',
'p257_363',
'p257_218',
'p232_210',
'p257_292',
'p232_065',
'p232_219',
'p257_246',
'p257_366',
'p232_188',
'p232_137',
'p257_172',
'p232_371',
'p232_206',
'p232_184',
'p232_090',
'p257_198',
'p257_066',
'p257_082',
'p232_141',
'p257_369',
'p232_375',
'p257_058',
'p232_225',
'p232_216',
'p257_308',
'p257_289',
'p232_359',
'p232_176',
'p257_102',
'p232_013',
'p232_126',
'p232_147',
'p232_250',
'p257_392',
'p257_348',
'p257_256',
'p257_109',
'p232_081',
'p257_158',
'p232_088',
'p257_389',
'p232_100',
'p257_104',
'p257_062',
'p257_197',
'p232_113',
'p257_196',
'p232_150',
'p232_200',
'p232_244',
'p257_205',
'p257_115',
'p257_412',
'p232_280',
'p257_354',
'p257_274',
'p257_219',
'p257_054',
'p257_239',
'p232_201',
'p257_131',
'p232_195',
'p257_320',
'p257_347',
'p257_028',
'p232_382',
'p257_030',
'p257_069',
'p257_262',
'p232_019',
'p257_090',
'p232_369',
'p232_361',
'p232_314',
'p257_155',
'p257_295',
'p232_089',
'p257_416',
'p232_005',
'p257_003',
'p257_013',
'p232_409',
'p232_121',
'p257_050',
'p257_105',
'p257_100',
'p232_265',
'p257_121',
'p232_051',
'p257_055',
'p232_076',
'p232_161',
'p257_380',
'p257_286',
'p232_390',
'p257_169',
'p232_310',
'p257_183',
'p232_414',
'p257_139',
'p257_267',
'p257_167',
'p257_161',
'p257_044',
'p257_263',
'p232_353',
'p257_201',
'p232_288',
'p257_375',
'p257_176',
'p232_305',
'p257_417',
'p232_363',
'p257_103',
'p257_190',
'p232_202',
'p257_059',
'p257_312',
'p257_071',
'p257_378',
'p232_040',
'p232_072',
'p257_255',
'p232_327',
'p257_376',
'p257_018',
'p257_361',
'p232_131',
'p232_029',
'p232_123',
'p232_285',
'p257_241',
'p257_186',
'p232_323',
'p257_316',
'p232_254',
'p257_151',
'p232_410',
'p257_310',
'p257_214',
'p257_331',
'p232_232',
'p232_074',
'p257_242',
'p232_096',
'p257_041',
'p232_293',
'p232_094',
'p232_329',
'p232_055',
'p257_004',
'p257_319',
'p257_223',
'p257_407',
'p232_203',
'p257_325',
'p232_286',
'p257_204',
'p257_175',
'p232_073',
'p257_299',
'p257_232',
'p257_291',
'p232_098',
'p257_280',
'p232_174',
'p257_324',
'p232_326',
'p232_128',
'p257_032',
'p232_010',
'p257_017',
'p232_059',
'p232_101',
'p257_372',
'p257_336',
'p257_023',
'p232_041',
'p257_002',
'p232_294',
'p232_354',
'p257_165',
'p232_268',
'p257_410',
'p257_061',
'p257_119',
'p232_062',
'p257_095',
'p232_209',
'p232_324',
'p257_293',
'p232_388',
'p257_428',
'p257_226',
'p257_024',
'p257_351',
'p257_397',
'p257_350',
'p257_251',
'p232_083',
'p232_109',
'p232_169',
'p232_386',
'p232_134',
'p232_172',
'p257_355',
'p257_272',
'p232_057',
'p257_421',
'p257_195',
'p257_301',
'p257_124',
'p232_240',
'p232_336',
'p257_386',
'p257_383',
'p257_434',
'p257_144',
'p257_051',
'p257_282',
'p232_325',
'p232_214',
'p232_243',
'p257_323',
'p232_234',
'p257_042',
'p232_311',
'p257_094',
'p257_333',
'p257_080',
'p232_241',
'p257_010',
'p232_148',
'p257_304',
'p232_264',
'p257_141',
'p257_332',
'p257_429',
'p257_063',
'p232_087',
'p232_016',
'p257_238',
'p232_185',
'p257_001',
'p232_067',
'p232_303',
'p257_424',
'p232_282',
'p232_063',
'p257_396',
'p257_390',
'p257_353',
'p257_019',
'p232_339',
'p232_043',
'p257_179',
'p257_147',
'p232_020',
'p232_045',
'p232_275',
'p257_420',
'p232_292',
'p257_326',
'p232_362',
'p257_329',
'p257_423',
'p232_158',
'p257_073',
'p232_276',
'p232_253',
'p257_281',
'p232_365',
'p257_112',
'p232_415',
'p232_015',
'p232_136',
'p257_309',
'p257_122',
'p257_123',
'p257_327',
'p257_387',
'p232_255',
'p232_245',
'p257_233',
'p232_238',
'p257_213',
'p232_316',
'p257_132',
'p257_431',
'p257_160',
'p257_064',
'p257_221',
'p232_251',
'p232_247',
'p257_200',
'p232_391',
'p232_030',
'p257_341',
'p257_060',
'p257_159',
'p232_394',
'p257_368',
'p257_210',
'p232_027',
'p232_047',
'p257_035',
'p257_296',
'p232_352',
'p257_025',
'p257_076',
'p257_229',
'p257_349',
'p232_182',
'p257_391',
'p232_331',
'p232_271',
'p257_278',
'p232_181',
'p232_320',
'p232_332',
'p257_230',
'p257_150',
'p257_116',
'p232_031',
'p257_344',
'p232_125',
'p232_270',
'p232_139',
'p232_228',
'p257_305',
'p232_116',
'p257_194',
'p257_177',
'p232_078',
'p232_023',
'p232_258',
'p257_118',
'p257_235',
'p257_149',
'p257_388',
'p232_115',
'p232_231',
'p257_036',
'p232_187',
'p257_307',
'p257_315',
'p232_036',
'p232_266',
'p257_245',
'p232_272',
'p257_096',
'p257_433',
'p257_269',
'p257_254',
'p232_299',
'p257_328',
'p232_340',
'p257_220',
'p257_156',
'p232_079',
'p232_118',
'p257_162',
'p232_133',
'p232_298',
'p257_047',
'p257_311',
'p257_206',
'p232_335',
'p232_218',
'p257_279',
'p257_083',
'p257_313',
'p257_290',
'p257_249',
'p257_216',
'p232_213',
'p257_152',
'p232_227',
'p232_070',
'p232_138',
'p257_022',
'p232_099',
'p232_146',
'p257_098',
'p232_108',
'p232_038',
'p232_224',
'p257_303',
'p257_244',
'p232_337',
'p257_411',
'p257_173',
'p232_167',
'p257_294',
'p232_171',
'p232_207',
'p257_287',
'p257_321',
'p257_277',
'p232_351',
'p257_111',
'p232_300',
'p257_426',
'p232_050',
'p257_365',
'p232_309',
'p232_296',
'p257_318',
'p232_196',
'p232_066',
'p232_221',
'p232_085',
'p232_364',
'p257_419',
'p257_371',
'p257_037',
'p232_385',
'p257_430',
'p232_217',
'p232_086',
'p232_384',
'p257_237',
'p257_185',
'p232_153',
'p257_265',
'p257_189',
'p257_384',
'p232_164',
'p257_125',
'p232_175',
'p232_358',
'p257_285',
'p232_112',
'p232_204',
'p232_349',
'p232_350',
'p232_155',
'p257_015',
'p232_058',
'p257_079',
'p232_152',
'p232_346',
'p232_312',
'p257_007',
'p232_215',
'p232_001',
'p257_129',
'p232_143',
'p257_136',
'p257_340',
'p257_097',
'p257_127',
'p232_049',
'p257_006',
'p257_405',
'p257_087',
'p257_370',
'p257_302',
'p257_016',
'p232_413',
'p232_236',
'p232_229',
'p232_322',
'p232_035',
'p232_145',
'p257_404',
'p232_046',
'p257_379',
'p257_065',
'p257_215',
'p232_002',
'p257_297',
'p257_317',
'p232_011',
'p232_124',
'p257_120',
'p232_252',
'p257_357',
'p232_257',
'p257_257',
'p257_422',
'p257_078',
'p232_191',
'p257_356',
'p232_267',
'p232_370',
'p257_178',
'p257_393',
'p257_374',
'p257_011',
'p232_025',
'p257_099',
'p232_412',
'p232_093',
'p232_260',
'p257_248',
'p232_343',
'p257_145',
'p257_252',
'p232_107',
'p257_033',
'p232_009',
'p232_328',
'p232_021',
'p232_379',
'p257_092',
'p257_187',
'p232_069',
'p232_235',
'p232_355',
'p257_202',
'p257_414',
'p232_120',
'p232_274',
'p232_156',
'p232_162',
'p232_373',
'p257_334',
'p232_198',
'p232_135',
'p257_228',
'p232_044',
'p232_302',
'p257_367',
'p257_166',
'p257_275',
'p232_404',
'p257_394',
'p232_378',
'p257_052',
'p257_337',
'p232_042',
'p232_315',
'p257_273',
'p257_034',
'p232_367',
'p257_373',
'p232_199',
'p257_009',
'p257_247',
'p232_160',
'p232_142',
'p257_415',
'p232_082',
'p232_306',
'p257_345',
'p257_117',
'p232_407',
'p232_208',
'p257_266',
'p232_290',
'p257_203',
'p232_154',
'p232_080',
'p232_151',
'p232_318',
'p232_307',
'p257_075',
'p257_427',
'p257_081',
'p257_406',
'p232_114',
'p257_181',
'p257_377',
'p257_209',
'p232_189',
'p232_197',
'p257_085',
'p232_053',
'p257_261',
'p257_164',
'p257_409',
'p232_402',
'p257_170',
'p257_027',
'p257_342',
'p257_400',
'p257_352',
'p257_067',
'p257_193',
'p257_236',
'p257_101',
'p232_095',
'p232_398',
'p232_110',
'p257_212',
'p232_127',
'p257_040',
'p257_072',
'p257_300',
'p257_270',
'p232_223',
'p232_173',
'p257_146',
'p257_288',
'p232_039',
'p232_389',
'p257_163',
'p257_070',
'p232_279',
'p232_383',
'p257_243',
'p232_291',
'p232_048',
'p257_045',
'p232_372',
'p232_403',
'p232_405',
'p232_092',
'p257_168',
'p232_348',
'p257_106',
'p232_032',
'p257_077',
'p257_154',
'p232_056',
'p257_231',
'p257_148',
'p232_392',
'p257_031',
'p257_338',
'p232_220',
'p232_317',
'p257_091',
'p232_396',
'p232_242',
'p257_043',
'p257_048',
'p232_368',
'p232_052',
'p257_207',
'p232_347',
'p257_240',
'p232_281',
'p257_020',
'p232_186',
'p257_113',
'p257_174',
'p232_400',
'p257_339',
'p232_012',
'p257_359',
'p232_084',
'p232_017',
'p257_222',
'p232_103',
'p232_193',
'p232_393',
'p257_089',
'p232_387',
'p257_026',
'p232_064',
'p257_401',
'p257_408',
'p257_053',
'p257_184',
'p257_057',
'p232_180',
'p257_142',
'p232_256',
'p257_381',
'p232_104',
'p232_289',
'p232_177',
'p232_411',
'p257_114',
'p257_227',
'p257_138',
'p232_308',
'p257_211',
'p232_399',
'p257_130',
'p257_403',
'p232_163',
'p257_346',
'p232_194',
'p232_287',
'p257_029',
'p257_268',
'p232_397',
'p232_006',
'p232_239',
'p257_335',
'p257_153',
'p257_014',
'p232_366',
'p232_342',
'p257_088',
'p257_382',
'p257_008',
'p232_075',
'p257_107',
'p257_188',
'p257_413',
'p232_129',
'p257_358',
'p232_077',
'p232_338',
'p232_130',
'p257_250',
'p232_273',
'p257_298',
'p232_034',
'p257_225',
'p232_295',
'p257_126',
'p257_128',
'p257_258',
'p232_205',
'p232_319',
'p257_199',
'p257_038',
'p232_360',
'p257_322',
'p232_301',
'p257_253',
'p257_110',
'p232_105',
'p257_137',
'p232_330',
'p257_343',
'p257_140',
'p232_068',
'p232_380',
'p257_074',
'p257_399',
'p232_165',
'p232_140',
'p257_395',
'p232_381',
'p232_007',
'p232_297',
'p257_360',
'p232_284',
'p232_132',
'p232_356',
'p257_039',
'p232_144',
'p257_046',
'p232_333',
'p232_190',
'p232_374',
'p257_084',
'p257_425',
'p257_068',
'p257_108',
'p232_097',
'p257_314',
'p257_224',
'p232_261',
'p257_086',
'p232_102',
'p232_246',
'p257_276',
'p232_277',
'p232_159',
'p232_283',
'p257_306']


for test_file in test_file_list:
    ex = Experiment('Waveunet Prediction', ingredients=[config_ingredient])
    ex.observers.append(FileStorageObserver.create('my_runs/Predictions/' + test_file))

    @ex.config
    def cfg():
        model_path = os.path.join("checkpoints", "105373", "105373-450225") # Load model from checkpoints folder. E.g. a particular model, "105373-450225" from "checkpoints/105373"
        input_path = os.path.join("audio_examples", "noisy_testset_wav", test_file + ".wav") # Which audio file to separate. In this example, within path "audio_examples/noisy_testset_wav/p*.wav"
        output_path = None # Where to save results. Default: Same location as input.

    @ex.automain
    def main(cfg, model_path, input_path, output_path):
        model_config = cfg["model_config"]
        Estimate_Sources.produce_source_estimates(model_config, model_path, input_path, output_path)
